<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('任务列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								任务名称：<input type="text" name="taskName"/>
							</li>

							<li>
								任务类型：
								<select name="taskType" th:with="type=${@dict.getType('fantasy_task_type')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								任务周期：
								<select name="taskPeriod" th:with="type=${@dict.getType('fantasy_task_period')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								起始任务：
								<select name="taskIsStart" th:with="type=${@dict.getType('fantasy_yes_no')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								随机任务：
								<select name="taskIsRand" th:with="type=${@dict.getType('fantasy_yes_no')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								任务链：
								<select name="taskIsChain" th:with="type=${@dict.getType('fantasy_yes_no')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="fantasy:fantasyTask:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit" onclick="$.operate.edit()" shiro:hasPermission="fantasy:fantasyTask:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del" onclick="$.operate.removeAll()" shiro:hasPermission="fantasy:fantasyTask:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="fantasy:fantasyTask:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('fantasy:fantasyTask:edit')}]];
        var removeFlag = [[${@permission.hasPermi('fantasy:fantasyTask:remove')}]];
        var prefix = ctx + "fantasy/fantasyTask";
		var taskTypeDatas = [[${@dict.getType('fantasy_task_type')}]];
		var taskPeriodDatas = [[${@dict.getType('fantasy_task_period')}]];
		var yesNoDatas = [[${@dict.getType('fantasy_yes_no')}]];
		var allocRewardFlag = [[${@permission.hasPermi('fantasy:fantasyTaskReward:add')}]];
		var allocCompletionConditionFlag = [[${@permission.hasPermi('fantasy:fantasyCompletionCondition:add')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "任务",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'taskId', 
					title : '任务id',
					visible: true
				},
				{
					field : 'taskName', 
					title : '任务名称',
					sortable: true
				},
				{
					field : 'taskDesc', 
					title : '任务描述',
					sortable: true
				},
				{
					field : 'taskType', 
					title : '任务类型',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(taskTypeDatas, value);
					}
				},
				{
					field : 'taskPeriod',
					title : '任务周期',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(taskPeriodDatas, value);
					}
				},
				{
					field : 'taskFrom', 
					title : '任务发起人',
					sortable: true
				},
				{
					field : 'taskTo', 
					title : '任务接收人',
					sortable: true
				},
				{
					field : 'taskItem', 
					title : '任务道具',
					sortable: true
				},
				{
					field : 'keyWord',
					title : '关键字',
					sortable: true
				},
				{
					field : 'taskIsRand', 
					title : '随机任务',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(yesNoDatas, value);
					}
				},
				{
					field : 'taskIsStart', 
					title : '起始任务',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(yesNoDatas, value);
					}
				},
				{
					field : 'taskIsChain',
					title : '任务链',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(yesNoDatas, value);
					}
				},
				{
					field : 'startTask',
					title : '开始任务id',
					sortable: true
				},
				{
					field : 'taskPredecessorId', 
					title : '前置任务id',
					sortable: true
				},
				{
					field : 'taskSuccessorId', 
					title : '后续任务id',
					sortable: true
				},
				{
					field : 'taskResp',
					title : '任务回复',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注信息',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.taskId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.taskId + '\')"><i class="fa fa-remove"></i>删除</a>');
						actions.push('<a class="btn btn-success btn-xs ' + allocRewardFlag + '" href="#" onclick="allocReward(\'' + row.taskId + '\')"><i class="fa fa-edit"></i>奖励</a> ');
						actions.push('<a class="btn btn-success btn-xs ' + allocCompletionConditionFlag + '" href="#" onclick="allocCompletionCondition(\'' + row.taskId + '\')"><i class="fa fa-edit"></i>完成条件</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

		// 任务管理-分配奖励
		function allocReward(taskId) {
			var url = prefix + '/allocReward/' + taskId;
			$.modal.openTab("分配奖励", url);
		}

		// 任务管理-分配完成条件
		function allocCompletionCondition(taskId) {
			var url = prefix + '/allocCompletionCondition/' + taskId;
			$.modal.openTab("分配完成条件", url);
		}


    </script>
</body>
</html>